<template>
  <div class="first_B">
    <Loading v-if="isloading1"></Loading>
    <div class="swiper">
      <SwiperKind1 />
      <div class="tubiao iconfont icon-shangjia-">
        <span class="shangjia">附近商家</span>
      </div>
      <div
        class="shop"
        v-for="(item, index) in list"
        :key="index"
        @click="ac(index)"
      >
        <ShopList :datas="item" />
      </div>
    </div>
    <Foot />
  </div>
</template>
<script>
import SwiperKind1 from "../components/compoents_B/SwiperKind1-B";
import Foot from "../components/footBar_comm";
import Loading from "../components/compoents_B/Loading";

import ShopList from "../components/compoents_B/ShopList_B";
export default {
  name: "first_B",
  data: function () {
    return {
      list: [],
      tra: null,
      isloading1: true,
    };
  },
  components: {
    SwiperKind1,
    ShopList,
    Foot,
    Loading,
  },
  methods: {
    ac(index) {
      console.log(this.list[index].id);
      localStorage.setItem("shuju", JSON.stringify(this.list[index].id));
      this.$router.push({ name: "Shopinfor" });
    },
  },
  created() {
    this.isLoading1 = false;
    this.tra = JSON.parse(localStorage.getItem("tra"));
    this.$store.state.title = this.tra.address;

    this.$axios
      .get("https://elm.cangdu.org/shopping/restaurants", {
        params: {
          //this.tra.latitude
          //this.tra.longitude
          latitude: this.tra.latitude,
          longitude: this.tra.longitude,
        },
      })
      .then((res) => {
        //console.log(res)
        this.list = res;
        // this.tra = JSON.parse(localStorage.getItem("tra"))
        // console.log(tar);
        localStorage.setItem("shop", JSON.stringify(this.list));
        //console.log(JSON.stringify(this.list))
        this.isloading1 = false;
      })
      .catch((err) => console.log(err));
  },
};
</script>
<style lang="less">
.tubiao {
  width: 100%;
  height: 20%;
  background-color: white;
  font-size: 24px;
  color: #7575;
  margin-top: 10px;
}
.shangjia {
  font-size: 16px;
}
</style>